cmake_minimum_required (VERSION 3.5.0)

project(robowalker_vision2021)
SET(BIN_NAME "run_this")

set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS   "${CMAKE_CXX_FLAGS} -std=c++11 -O3")

# include_directories("D://opencv-mingw64//opencv-4.5.1//build//install//include//opencv2" 
# "D://opencv-mingw64//opencv-4.5.1//build//install//include" "D://eigen-3.3.8")
# link_directories("D://opencv-mingw64//opencv-4.5.1//build//install//x64//mingw//lib")

# add_executable(${PROJECT_NAME} main.cpp findArmorBoxes.cpp hog_svm.cpp torch.cpp)
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR})
# target_link_libraries(${PROJECT_NAME} libpthread.dll.a libopencv_world451.dll.a)

message(STATUS "Target OS: ${CMAKE_SYSTEM_NAME}")
message(STATUS "Target Architecture: ${CMAKE_SYSTEM_PROCESSOR}")

find_package(Threads)
find_package(OpenCV  REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "Project source dir: ${PROJECT_SOURCE_DIR}/")

include_directories(${OpenCV_INCLUDE_DIRS})
include_directories("/usr/local/include/eigen3")

include_directories("ArmorBox/include")
include_directories("Camera/include")
include_directories("Kalman/include")
include_directories("PowerRune/include")
include_directories("Serial/include")
include_directories("Network/include") 
include_directories("Utils/include")
include_directories("Utils/include/Log")
include_directories("Utils/include/Thread")



link_directories("/usr/local/lib/")

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR})

# file(GLOB_RECURSE SOURCE ${PROJECT_SOURCE_DIR} *.cpp)
FILE(GLOB_RECURSE SOURCE "ArmorBox/src/*.cpp" "Camera/src/*cpp" "Kalman/src/*.cpp" "PowerRune/src/*.cpp" "Serial/src/*.cpp" "Utils/src/*.cpp" "Network/src/*.cpp")
message(STATUS "Source files: ${SOURCE}")

# Choose hikvision libs according to architecture: x86_64 or aarch64
if ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
    file(GLOB HIKVISION_LIBS "Camera/lib/x86_64/*.so")
elseif( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
    file(GLOB HIKVISION_LIBS "Camera/lib/aarch64/*.so")
else()
    message(FATAL_ERROR "unsupported architecture.")
endif ()
message(STATUS "Hikvision libs founded: ${HIKVISION_LIBS}")

add_executable(${PROJECT_NAME} main.cpp ${SOURCE})

target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
target_link_libraries(${PROJECT_NAME} ${HIKVISION_LIBS})




 
